package com.asiainfo.dacp.datastash.broker.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;

import com.asiainfo.dacp.datastash.broker.common.enums.BatchTypeEnum;

public class BatchUtils {

	
	public static String batchNo(String batchType, int batchOffset) {

		SimpleDateFormat sdf = null;
		Calendar calendar = GregorianCalendar.getInstance();

		if (BatchTypeEnum.DAY.value().equals(batchType)) {
			sdf = new SimpleDateFormat(BatchTypeEnum.DAY.label());
			calendar.add(Calendar.DATE, batchOffset);
		} else if (BatchTypeEnum.MON.value().equals(batchType)) {
			sdf = new SimpleDateFormat(BatchTypeEnum.MON.label());
			calendar.add(Calendar.MONTH, batchOffset);
		} else if (BatchTypeEnum.HOUR.value().equals(batchType)) {
			sdf = new SimpleDateFormat(BatchTypeEnum.HOUR.label());
			calendar.add(Calendar.HOUR, batchOffset);
		} else if (BatchTypeEnum.MINUTE.value().equals(batchType)) {
			sdf = new SimpleDateFormat(BatchTypeEnum.MINUTE.label());
			calendar.add(Calendar.MINUTE, batchOffset);
		}
		return sdf != null ? sdf.format(calendar.getTime()) : null;
	}
}
